home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Genie / Projects / AEA / Source / Sources / Descriptors / AEADescAppleEvent.cc < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-24  |  2.9 KB  |  115 lines

  1. /*    ====================
  2.  *    AEADescAppleEvent.cc
  3.  *    ====================
  4.  */
  5.  
  6. #include "AEADebugging.h"
  7.  
  8. #include <Errors.h>
  9.  
  10. #include "AEADescAppleEvent.hh"
  11.  
  12. AEADescAppleEvent::AEADescAppleEvent()
  13. {
  14. }
  15.  
  16. AEADescAppleEvent::AEADescAppleEvent(AEDesc inAEDesc)
  17. : AEADesc(inAEDesc)
  18. {
  19.     switch (inAEDesc.descriptorType) {
  20.         case typeAppleEvent:
  21.         case typeNull:
  22.             break;
  23.         default:
  24.             ThrowOSErr_(errAEWrongDataType);
  25.     }
  26. }
  27.  
  28. AEADescAppleEvent::AEADescAppleEvent(AEEventClass inEventClass, AEEventID inEventID, 
  29.         const AEAddressDesc &inTarget, short inReturnID, long inTransactionID)
  30. {
  31.     Create(inEventClass, inEventID, inTarget, inReturnID, inTransactionID);
  32. }
  33.  
  34. AEADescAppleEvent::~AEADescAppleEvent()
  35. {
  36.     // AEADesc already calls Dispose().
  37. }
  38.  
  39. void
  40. AEADescAppleEvent::Create(AEEventClass inEventClass, AEEventID inEventID, 
  41.         const AEAddressDesc &inTarget, short inReturnID, long inTransactionID)
  42. {
  43.     OSErr err = ::AECreateAppleEvent(inEventClass, inEventID, &inTarget, 
  44.         inReturnID, inTransactionID, &Ref());
  45.     ThrowIfOSErr_(err);
  46. }
  47.  
  48. void
  49. AEADescAppleEvent::GetParameter(AEKeyword inKeyword, DescType inDesiredType, 
  50.     DescType &outTypeCode, void *outDataPtr, Size inMaximumSize, Size &outActualSize) const
  51. {
  52.     OSErr err = ::AEGetParamPtr(&Ref(), inKeyword, inDesiredType, 
  53.         &outTypeCode, outDataPtr, inMaximumSize, &outActualSize);
  54.     ThrowIfOSErr_(err);
  55. }
  56.  
  57. void
  58. AEADescAppleEvent::GetParameter(AEKeyword inKeyword, DescType inDesiredType, 
  59.     AEDesc &outAEDesc) const
  60. {
  61.     OSErr err = ::AEGetParamDesc(&Ref(), inKeyword, inDesiredType, &outAEDesc);
  62.     ThrowIfOSErr_(err);
  63. }
  64.  
  65. void
  66. AEADescAppleEvent::GetAttribute(AEKeyword inKeyword, DescType inDesiredType, 
  67.     DescType &outTypeCode, void *outDataPtr, Size inMaximumSize, Size &outActualSize) const
  68. {
  69.     OSErr err = ::AEGetAttributePtr(&Ref(), inKeyword, inDesiredType, 
  70.         &outTypeCode, outDataPtr, inMaximumSize, &outActualSize);
  71.     ThrowIfOSErr_(err);
  72. }
  73.  
  74. void
  75. AEADescAppleEvent::PutParameter(AEKeyword inKeyword, DescType inTypeCode, 
  76.     const void *inDataPtr, Size inDataSize)
  77. {
  78.     OSErr err = ::AEPutParamPtr(&Ref(), inKeyword, inTypeCode, inDataPtr, inDataSize);
  79.     ThrowIfOSErr_(err);
  80. }
  81.  
  82. void
  83. AEADescAppleEvent::PutParameter(AEKeyword inKeyword, const AEDesc &inAEDesc)
  84. {
  85.     OSErr err = ::AEPutParamDesc(&Ref(), inKeyword, &inAEDesc);
  86.     ThrowIfOSErr_(err);
  87. }
  88.  
  89. void
  90. AEADescAppleEvent::PutParameter(AEKeyword inKeyword, AEADesc inDesc)
  91. {
  92.     PutParameter(inKeyword, inDesc.Ref());
  93. }
  94.  
  95. void
  96. AEADescAppleEvent::PutAttribute(AEKeyword inKeyword, DescType inTypeCode, 
  97.     const void *inDataPtr, Size inDataSize)
  98. {
  99.     OSErr err = ::AEPutAttributePtr(&Ref(), inKeyword, inTypeCode, inDataPtr, inDataSize);
  100.     ThrowIfOSErr_(err);
  101. }
  102.  
  103. void
  104. AEADescAppleEvent::PutAttribute(AEKeyword inKeyword, const AEDesc &inAEDesc)
  105. {
  106.     OSErr err = ::AEPutAttributeDesc(&Ref(), inKeyword, &inAEDesc);
  107.     ThrowIfOSErr_(err);
  108. }
  109.  
  110. void
  111. AEADescAppleEvent::PutAttribute(AEKeyword inKeyword, AEADesc inDesc)
  112. {
  113.     PutAttribute(inKeyword, inDesc.Ref());
  114. }
  115.